package design.Day02;

/**
* @description: 当前温度等信息
* @author: wangjun
* @create: 2022-01-11
*/
public class CurrentConditionDisplay implements Observer,DisplayElement{

    private float temp;
    private float humidity;
    private float pressure;

    private Subject subject;

    public void setSubject(Subject subject) {
        this.subject = subject;
        subject.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("CurrentConditionDisplay --> temp: " + temp + " humidity: " + humidity + " pressure: " + pressure);
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temp = temp;
        this.humidity = humidity;
        this.pressure = pressure;
        display();
    }
}
